Skip to content

fix(dbt-tools): move to dbt-integration 0.3.15 so the dbt adapter starts under Bun - #1368

Draft
ralphstodomingo wants to merge 6 commits into
mainfrom
fix/dbt-tools-dbt-integration-0.3
Draft

ralphstodomingo wants to merge 6 commits into
mainfrom
fix/dbt-tools-dbt-integration-0.3

Conversation

@ralphstodomingo

@ralphstodomingo ralphstodomingo commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1367

Type of change

  • Bug fix

What does this PR do?

Moves packages/dbt-tools from @altimateai/dbt-integration 0.2.14 to ^0.3.15. 0.2.x started its Python child through python-bridge, which fails under Bun (bluebird.promisifyAll on child_process throws Cannot access invalid private field (evaluating 'this.#stdin')), so the dbt-first path of sql_execute never ran. 0.3.x vendors the bridge and uses a plain fd-3 pipe; python-bridge and bluebird leave the lockfile. From 0.3.15, a bridge running inside a single-file executable writes its script to a temporary directory and removes it on exit, so the compiled binary starts the bridge too.

  • adapter.ts: 0.3.x's DBTProjectIntegrationAdapter takes a UnitTestParser and a SemanticModelParser; the Fusion integration no longer takes the cloud-variant detector (the Cloud integration still does).
  • copy-python.ts / release.yml / publish.ts: the vendored bridge finds node_python_bridge.py from the bundle's own location at runtime (fileURLToPath(import.meta.url)), so the python-bridge __dirname patch is gone. The build and the release smoke check now assert the new resolution instead of the patch.
  • Tests: build-adversarial.test.ts tested the removed patch. The checks in it that don't depend on the patch move to build-integrity.test.ts (no build-machine path in the bundle, Python packages copied, createRequire, byte-identical rebuilds). A new test runs the package as publish.ts lays it out, from another directory, and checks that it starts the bridge script next to its own bundle.

Claims

  • C1: Under Bun, the dbt-first path of sql_execute starts the dbt adapter and runs the query through dbt, from source and from the compiled binary.
  • C2: The compiled binary runs the bridge from a real directory, not from /$bunfs. No Python process and no temporary bridge directory is left after the call.
  • C3: altimate-dbt, laid out as publish.ts ships it and run by Node from another directory, starts the node_python_bridge.py next to its own bundle. The build and the release smoke check fail if a build-time path is baked into the bundle.
  • C4: adapter.ts builds the adapter with what 0.3.x's constructors take: both new parsers, and the cloud-variant detector for dbt Cloud only.

Residuals

  • R1: 0.3.15 was published on 2026-10-13, inside this repo's 3-day minimumReleaseAge. The lockfile pins it, and Bun applies that window only when it resolves a version, so installs from the lockfile take 0.3.15. The lockfile change for it is that one entry; its dependencies are the same as 0.3.13's.
  • R2: When the adapter can't start (no dbt in the venv, a broken project), sql_execute still falls back to the configured warehouse without saying why. That's unchanged by this PR.

How did you verify your code works?

sql_execute called through the real tool registry (debug agent build --tool sql_execute, no model turn), against a two-model dbt-core 1.11.7 / DuckDB project with its own venv, query select count(*) as n from customer_totals:

before this branch (ccc92cc)
compiled binary v0.12.7 release: falls back, "No warehouse configured" n = 2 via dbt
from source (Bun) main (2026-09-29): falls back, "No warehouse configured" n = 2 via dbt
  • Compiled binary: the bridge ran as /tmp/altimate-dbt-integration-<random>/bridge.py. Python processes were sampled every 200 ms; none was left after the call, and neither was the temporary directory.
  • From source, the bridge ran from @altimateai/dbt-integration@0.3.15/dist/node_python_bridge.py.
  • altimate-dbt as npm ships it (publish.ts layout, Node 22, run from another directory), execute --query …: [{"n": 2}], as on main.
  • packages/dbt-tools: typecheck clean, build verified, 88 tests pass. The relocation test fails when a fixed path is baked into the bundle. packages/opencode: typecheck clean.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Appendix: complexity delta

✅ No touched function changed in complexity (2 touched, 0 new, all under 10). Advisory, not a gate.

🤖 Generated with Claude Code

https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD

…rts under Bun

`dbt-tools` resolved `@altimateai/dbt-integration` 0.2.14, which spawns
its Python child through `python-bridge`. Under Bun that module fails
to load (`bluebird.promisifyAll(child_process)` throws on
`ChildProcess.prototype.stdin`), and past that, Bun's IPC to a non-JS
child closes after the first message. So the dbt-first path of
`sql_execute` never ran; the adapter silently fell back.

0.3.x vendors the bridge and talks newline JSON over a plain fd-3 pipe,
with no `python-bridge` or `bluebird` in the tree.

- `adapter.ts`: the 0.3.x constructors take `UnitTestParser` and
  `SemanticModelParser`; the Fusion integration no longer takes the
  cloud-variant detector (the Cloud integration still does).
- `copy-python.ts`: the vendored bridge resolves its script from the
  bundle's own location at runtime, so the `python-bridge` `__dirname`
  patch is gone; the build now fails if a build-time path is baked in.
  `build-adversarial.test.ts` tested only that patch and is removed;
  `build-integrity.test.ts` and the release smoke check assert the new
  invariant.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
@ralphstodomingo ralphstodomingo self-assigned this Sep 24, 2026
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

ralphstodomingo and others added 5 commits September 29, 2026 12:11
…published package from elsewhere

Restores the checks from the removed patch tests that do not depend on the patch:
no build-machine path anywhere in the bundle, altimate_python_packages copied,
__require from createRequire, and byte-identical consecutive builds.

Adds a runtime check the old suite only approximated: the package laid out as
publish.ts ships it, run by Node from another directory, starts the bridge
script next to its own bundle. A stand-in python records the spawn, so the test
needs neither Python nor dbt.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
…y starts the bridge

0.3.15 writes the bridge script to a temporary directory when it runs from a
single-file executable, instead of looking for it in `/$bunfs`. The lockfile pins
0.3.15; Bun applies `minimumReleaseAge` only when it resolves a version.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0172qrhMa5TQgETASi5hxMqD
@ralphstodomingo ralphstodomingo changed the title fix(dbt-tools): move to dbt-integration 0.3.13 so the dbt adapter starts under Bun fix(dbt-tools): move to dbt-integration 0.3.15 so the dbt adapter starts under Bun Oct 14, 2026
@ralphstodomingo

Copy link
Copy Markdown
Contributor Author

@codex review

Round on ccc92cc, the whole PR. Please review it against the numbered claims (C1–C4) and residuals (R1–R2) in the description. Report only a concrete trace that violates a numbered claim: a runtime (Bun from source, the compiled binary, or altimate-dbt under Node in the publish.ts layout), a dbt integration type and a project state where this branch fails a claim. Instances of R1 and R2 are not findings. A round with no claim violation ends review.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T13:21:49.006784Z ccc92cc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: ccc92cc431

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt-first sql_execute never runs under Bun: dbt-tools still resolves dbt-integration 0.2.x (python-bridge)

1 participant